package asimes.huawei;

import java.util.Scanner;

/**
 * Created by Liangweiwei on 2016/9/6.
 */
public class Main19 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int count = 0;
        for (int i = 7; i <= N; i = 7+ i) {
            count++;
        }
        for (int i = 0; i < N; i++) {
            if (i % 7 != 0) {
                int tmp = i;
                while (tmp >= 1) {
                    if (tmp % 10 == 7){
                        count++;
                        break;
                    }
                    tmp = tmp/10;
                }
            }
        }
        System.out.println(count);
    }
}
